// src/store/counterSlice.jsx
import { createSlice } from '@reduxjs/toolkit';

// 创建计数器的 slice
const counterSlice = createSlice({
  name: 'counter',
  initialState: { value: 0 },
  reducers: {
    increment: (state) => {
      state.value += 1;
    },
    decrement: (state) => {
      state.value -= 1;
    },
  },
});

// 导出 actions 和 reducer
export const { increment, decrement } = counterSlice.actions;
export default counterSlice.reducer;
